package com.penghaisoft.microwms.common;

import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

public class BaseEntity implements Serializable {
	private static final long serialVersionUID = 1l;

	@JSONField(serialize = true)
	protected String createBy;// 创建人
	
	@JSONField(serialize = true)
	protected Date gmtCreate;// 创建时间
	@JSONField(serialize = true)
	protected String gmtCreateStr;// 创建时间Str
	@JSONField(serialize = true)
	protected Date gmtCreateMax;// 创建时间max
	@JSONField(serialize = true)
	protected Date gmtCreateMin;// 创建时间min
	
	@JSONField(serialize = true)
	protected String lastModifiedBy;// 最后更新人
	
	@JSONField(serialize = true)
	protected Date gmtModified;// 更新时间
	@JSONField(serialize = true)
	protected String gmtModifiedStr;// 更新时间Str
	@JSONField(serialize = true)
	protected Date gmtModifiedMax;// 更新时间max
	@JSONField(serialize = true)
	protected Date gmtModifiedMin;// 更新时间min
	
	protected String activeFlag;// 有效标志 1-有效 0-无效
	@JSONField(serialize = true)
	protected String remark;// 备注
	@JSONField(serialize = true)
	protected String userDefined1;// 自定义1
	@JSONField(serialize = true)
	protected String userDefined2;// 自定义2
	@JSONField(serialize = true)
	protected String userDefined3;// 自定义3
	@JSONField(serialize = true)
	protected String userDefined4;// 自定义4
	@JSONField(serialize = true)
	protected String userDefined5;// 自定义5
	@JSONField(serialize = true)
	protected String userDefined6;// 自定义6
	@JSONField(serialize = true)
	protected String userDefined7;// 自定义7
	@JSONField(serialize = true)
	protected String userDefined8;// 自定义8
	@JSONField(serialize = true)
	protected String userDefined9;// 自定义9
	@JSONField(serialize = true)
	protected String userDefined10;// 自定义10

	public void preQuery() {
		if (StringUtils.isEmpty(activeFlag)) {
			setActiveFlag(Constant.CODE_ONE);
		}
	}

	/** 
	* @Title: preInsert 
	* @Description: 新增时候也更新upd时间和操作人
	* @author zhangxu 
	* @2017年4月21日:2017年4月21日:上午9:46:24
	* @param     
	* @return void    
	* @throws 
	*/
	public void preInsert() {
		if (ObjectUtils.isEmpty(gmtCreate)) {
			Date date = new Date();
			setGmtCreate(date);
			setGmtModified(date);
		}
	}

	public void preUpdate() {
		if (ObjectUtils.isEmpty(gmtModified)) {
			setGmtModified(new Date());
		}
	}

	public String getCreateBy() {
		return createBy;
	}

	public void setCreateBy(String createBy) {
		this.createBy = createBy;
	}

	public Date getGmtCreate() {
		return gmtCreate;
	}

	public void setGmtCreate(Date gmtCreate) {
		this.gmtCreate = gmtCreate;
		if (gmtCreate!=null) {
			setGmtCreateStr(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(gmtCreate));
		}
	}

	public String getLastModifiedBy() {
		return lastModifiedBy;
	}

	public void setLastModifiedBy(String lastModifiedBy) {
		this.lastModifiedBy = lastModifiedBy;
	}

	public Date getGmtModified() {
		return gmtModified;
	}

	public void setGmtModified(Date gmtModified) {
		this.gmtModified = gmtModified;
		if (gmtModified!=null) {
        	setGmtModifiedStr(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(gmtModified));
		}
	}

	public String getActiveFlag() {
		return activeFlag;
	}

	public void setActiveFlag(String activeFlag) {
		this.activeFlag = activeFlag;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getUserDefined1() {
		return userDefined1;
	}

	public void setUserDefined1(String userDefined1) {
		this.userDefined1 = userDefined1;
	}

	public String getUserDefined2() {
		return userDefined2;
	}

	public void setUserDefined2(String userDefined2) {
		this.userDefined2 = userDefined2;
	}

	public String getUserDefined3() {
		return userDefined3;
	}

	public void setUserDefined3(String userDefined3) {
		this.userDefined3 = userDefined3;
	}

	public String getGmtCreateStr() {
		return gmtCreateStr;
	}

	public void setGmtCreateStr(String gmtCreateStr) {
		this.gmtCreateStr = gmtCreateStr;
	}


	public String getGmtModifiedStr() {
		return gmtModifiedStr;
	}

	public void setGmtModifiedStr(String gmtModifiedStr) {
		this.gmtModifiedStr = gmtModifiedStr;
	}

	public Date getGmtCreateMax() {
		return gmtCreateMax;
	}

	public void setGmtCreateMax(Date gmtCreateMax) {
		this.gmtCreateMax = gmtCreateMax;
	}

	public Date getGmtCreateMin() {
		return gmtCreateMin;
	}

	public void setGmtCreateMin(Date gmtCreateMin) {
		this.gmtCreateMin = gmtCreateMin;
	}

	public Date getGmtModifiedMax() {
		return gmtModifiedMax;
	}

	public void setGmtModifiedMax(Date gmtModifiedMax) {
		this.gmtModifiedMax = gmtModifiedMax;
	}

	public Date getGmtModifiedMin() {
		return gmtModifiedMin;
	}

	public void setGmtModifiedMin(Date gmtModifiedMin) {
		this.gmtModifiedMin = gmtModifiedMin;
	}

	public String getUserDefined4() {
		return userDefined4;
	}

	public void setUserDefined4(String userDefined4) {
		this.userDefined4 = userDefined4;
	}

	public String getUserDefined5() {
		return userDefined5;
	}

	public void setUserDefined5(String userDefined5) {
		this.userDefined5 = userDefined5;
	}

	public String getUserDefined6() {
		return userDefined6;
	}

	public void setUserDefined6(String userDefined6) {
		this.userDefined6 = userDefined6;
	}

	public String getUserDefined7() {
		return userDefined7;
	}

	public void setUserDefined7(String userDefined7) {
		this.userDefined7 = userDefined7;
	}

	public String getUserDefined8() {
		return userDefined8;
	}

	public void setUserDefined8(String userDefined8) {
		this.userDefined8 = userDefined8;
	}

	public String getUserDefined9() {
		return userDefined9;
	}

	public void setUserDefined9(String userDefined9) {
		this.userDefined9 = userDefined9;
	}

	public String getUserDefined10() {
		return userDefined10;
	}

	public void setUserDefined10(String userDefined10) {
		this.userDefined10 = userDefined10;
	}
}
